<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
	  xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
<style>
	.fileinput-button {
		position: relative;
		display: inline-block;
		overflow: hidden;
	}
	.fileinput-button input{
		position:absolute;
		right: 0px;
		top: 0px;
		opacity: 0;
		-ms-filter: 'alpha(opacity=0)';
		font-size: 200px;
	}
</style>

<div class="container-div">
	<div class="row">
		<div class="col-sm-12 search-collapse">
			<form id="role-form">
				<div class="select-list">
					<ul>
						<li>标签名：<input type="text" name="label" /></li>
						<li><a class="btn btn-primary btn-rounded btn-sm"
							   onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							<a class="btn btn-warning btn-rounded btn-sm"
							   onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
						</li>
					</ul>
				</div>
			</form>
		</div>

		<div class="btn-group-sm hidden-xs" id="toolbar" role="group">

			<a class="btn btn-success" onclick="addFlag()"
			   shiro:hasPermission="phone:phones:add"> <i class="fa fa-plus"></i>
				新增
			</a>
			<!--<a class="btn btn-primary btn-edit disabled"
					onclick="editFlag()" shiro:hasPermission="phone:phones:edit">
				<i class="fa fa-edit"></i> 修改
			</a> -->
			<a class="btn btn-danger btn-del disabled"
				onclick="$.operate.removeAll()"
				shiro:hasPermission="system:role:remove"> <i
				class="fa fa-remove"></i> 删除
			</a>

		</div>

		<div class="col-sm-12 select-table table-striped">
			<table id="bootstrap-table" data-mobile-responsive="true"></table>
		</div>
	</div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var prefix = ctx + "phone/";

	function addFlag() {
        var url = prefix + '/add';
        $.modal.open("添加标签", url, '600', '300');
    }
    function editFlagData(id) {
        var url = prefix + '/edit/'+id;
        $.modal.open("编辑标签", url, '600', '300');
    }

	var editFlag = [[${@permission.hasPermi('phone:phones:edit')}]];
    var removeFlag = [[${@permission.hasPermi('phone:phones:remove')}]];
    $(function() {
        var options = {
            url: prefix + "/label/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            sortName: "createAt", // 排序字段
            modalName: "手机号码",
            search: false,
            showExport: false,
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    visible: false
                },
                {
                    field: 'label',
                    title: '标签名',
                },
                {
                    field: 'createAt',
                    title: '创建时间',
                    sortable: true
                },
                {
                    field: 'updateAt',
                    title: '更新时间'
                },
                {
                    field: 'remark',
                    title: '备注'
                },
                {
                    title: '操作',
                    field: 'id',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="editFlagData(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs  ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a> ');
                        return actions.join('');
                    }
                }
            ]
        };
        $.table.init(options);
    });

</script>
</body>
</html>